package com.ofood.springcloud.service;

import com.ofood.springcloud.domain.Food;
import com.ofood.springcloud.domain.Result;
import com.ofood.springcloud.service.impl.FoodFeignHystrixService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.concurrent.TimeUnit;

@Component
@FeignClient(value = "ofood-food-hystrix-provider",fallback = FoodFeignHystrixService.class)
public interface IFoodFeignService {
    @PostMapping("/food/create")
    public Result create(@RequestBody Food food);

    @GetMapping("/food/get/{foodId}")
    public Result getFoodById(@PathVariable("foodId") long foodId);

    @GetMapping("/food/get/timeout/hystrix")
    public String getFoodTimeoutHystrix();

    @GetMapping("/food/get/error/hystrix")
    public String getFoodErrorHystrix();
}
